#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2018, Niklas Hauser
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------


def init(module):
    module.name = ":driver:mcp2515"
    module.description = "MPC2515 External CAN Controller"


def prepare(module, options):
    module.add_option(
        EnumerationOption(
            name="clock",
            enumeration=["16MHz", "20MHz"],
            description="Used clock for the MCP2515. The device configuration "
                "is selected according to the clock speed.",
            default="16MHz"))

    module.depends(
        ":architecture:accessor",
        ":architecture:assert",
        ":architecture:can",
        ":architecture:clock",
        ":architecture:delay",
        ":debug")
    return True

def build(env):
    env.outbasepath = "modm/src/modm/driver/can"
    env.copy("mcp2515.hpp")
    env.copy("mcp2515_impl.hpp")
    env.copy("mcp2515_bit_timings.hpp")
    env.copy("mcp2515_definitions.hpp")
    env.template("mcp2515.cpp.in")
